<?php

error_reporting(E_ALL);

/**
 * untitledModel - class.ControladorCurso.php
 *
 * $Id$
 *
 * This file is part of untitledModel.
 *
 * Automatically generated on 04.12.2011, 19:24:30 with ArgoUML PHP module 
 * (last revised $Date: 2010-01-12 20:14:42 +0100 (Tue, 12 Jan 2010) $)
 *
 * @author firstname and lastname of author, <author@example.org>
 */

if (0 > version_compare(PHP_VERSION, '5')) {
    die('This file was generated for PHP 5');
}

/**
 * include Cursos
 *
 * @author firstname and lastname of author, <author@example.org>
 */
require_once('class.Cursos.php');

/**
 * include ModeloCursos
 *
 * @author firstname and lastname of author, <author@example.org>
 */
require_once('class.ModeloCursos.php');

/**
 * include Usuarios
 *
 * @author firstname and lastname of author, <author@example.org>
 */
require_once('class.Usuarios.php');

/**
 * include VistaCurso
 *
 * @author firstname and lastname of author, <author@example.org>
 */
require_once('class.VistaCurso.php');

/* user defined includes */
// section -64--88-1-105--75424b28:1340c1872aa:-8000:0000000000000ACC-includes begin
// section -64--88-1-105--75424b28:1340c1872aa:-8000:0000000000000ACC-includes end

/* user defined constants */
// section -64--88-1-105--75424b28:1340c1872aa:-8000:0000000000000ACC-constants begin
// section -64--88-1-105--75424b28:1340c1872aa:-8000:0000000000000ACC-constants end

/**
 * Short description of class ControladorCurso
 *
 * @access public
 * @author firstname and lastname of author, <author@example.org>
 */
class ControladorCurso
{
    // --- ASSOCIATIONS ---


    // --- ATTRIBUTES ---

    /**
     * Short description of attribute modelo
     *
     * @access public
     * @var ModeloCursos
     */
    public $modelo = null;

    /**
     * Short description of attribute vista
     *
     * @access public
     * @var VistaCursos
     */
    public $vista = null;

    /**
     * Short description of attribute curso
     *
     * @access public
     * @var Cursos
     */
    public $curso = null;

    /**
     * Short description of attribute usuarios
     *
     * @access public
     * @var Ususarios
     */
    public $usuarios = null;

    /**
     * Short description of attribute mensaje
     *
     * @access public
     * @var String
     */
    public $mensaje = null;

    // --- OPERATIONS ---

    /**
     * Short description of method Lista
     *
     * @access public
     * @author firstname and lastname of author, <author@example.org>
     * @return mixed
     */
    public function Lista()
    {
        // section -64--88-1-105--75424b28:1340c1872aa:-8000:0000000000000ADA begin
		$cadena=$this->modelo->GetAllRows();
		
		$this->vista->Lista("header.php",$cadena);
		$this->vista->Lista("VistaListaCursos.php",$cadena);
		$this->vista->Lista("footer.php",$cadena);
		exit();
        // section -64--88-1-105--75424b28:1340c1872aa:-8000:0000000000000ADA end
    }

    /**
     * Short description of method Alta
     *
     * @access public
     * @author firstname and lastname of author, <author@example.org>
     * @return mixed
     */
    public function Alta($datos)
    {
        // section -64--88-1-105--75424b28:1340c1872aa:-8000:0000000000000AE3 begin

			$this->modelo->InsertRow($datos);
			$this->Lista();
			$this->mensaje="Curso registrado con Exito";
        // section -64--88-1-105--75424b28:1340c1872aa:-8000:0000000000000AE3 end
    }
	  
	  public function Mostrar()
    {
        // section 10-0-101-116-75074dcc:133e14e2698:-8000:00000000000017A6 begin
			$datos= $this->modelo->SelectMaestro();	
			
			$this->vista->Editar("header.php", $datos);
			$this->vista->Editar("VistaAltaCursos.php",$datos);
			$this->vista->Editar("footer.php",$datos);
				exit();
	
        // section 10-0-101-116-75074dcc:133e14e2698:-8000:00000000000017A6 end
    }
	 public function MostrarBorrar($valorid)
    {
        // section 10-0-101-116-75074dcc:133e14e2698:-8000:00000000000017A6 begin
				$cadena= $this->modelo->GetId($valorid);				
				$this->vista->Borra("header.php",$cadena);
				$this->vista->Borra("VistaBajaCursos.php",$cadena);
				$this->vista->Borra("footer.php",$cadena);
				exit();
				
	
        // section 10-0-101-116-75074dcc:133e14e2698:-8000:00000000000017A6 end
    }
	 public function MostrarEditar($valorid)
    {
        // section 10-0-101-116-75074dcc:133e14e2698:-8000:00000000000017A6 begin
	
				$cadena= $this->modelo->GetId($valorid);
				$this->vista->Editar("header.php",$cadena);
				$this->vista->Editar("VistaEditarCursos.php",$cadena);
				$this->vista->Editar("footer.php",$cadena);
				exit();
				
	
        // section 10-0-101-116-75074dcc:133e14e2698:-8000:00000000000017A6 end
    }

    /**
     * Short description of method Borrar
     *
     * @access public
     * @author firstname and lastname of author, <author@example.org>
     * @return mixed
     */
    public function Borrar($id)
    {
        // section -64--88-1-105--75424b28:1340c1872aa:-8000:0000000000000AE5 begin
		
		$this->modelo->DeleteRow($id);
		$this->Lista();
		exit();
        // section -64--88-1-105--75424b28:1340c1872aa:-8000:0000000000000AE5 end
    }

    /**
     * Short description of method Buscar
     *
     * @access public
     * @author firstname and lastname of author, <author@example.org>
     * @return mixed
     */
    public function Buscar()
    {
        // section -64--88-1-105--75424b28:1340c1872aa:-8000:0000000000000AE7 begin
        // section -64--88-1-105--75424b28:1340c1872aa:-8000:0000000000000AE7 end
    }

    /**
     * Short description of method Editar
     *
     * @access public
     * @author firstname and lastname of author, <author@example.org>
     * @return mixed
     */
    public function Editar($datos)
    {
        // section -64--88-1-105--75424b28:1340c1872aa:-8000:0000000000000AFA begin
			$this->modelo->UpdateRow($datos);
			$this->Lista();
			exit();
        // section -64--88-1-105--75424b28:1340c1872aa:-8000:0000000000000AFA end
    }

    /**
     * Short description of method ControladorCursos
     *
     * @access public
     * @author firstname and lastname of author, <author@example.org>
     * @return mixed
     */
    public function ControladorCurso()
    {
        // section -64--88-1-105--75424b28:1340c1872aa:-8000:0000000000000AFC begin
		$this->modelo = new ModeloCursos();		
		$this->vista = new VistaCurso();
		$this->usuarios = new Usuarios();
		$this->cursos = new Cursos();
		
		if ($this->usuarios->IsLogged()==true && @$_REQUEST['opcion'] == null && @$_REQUEST['registrousr'] == null && @$_REQUEST['borrar'] == null && @$_REQUEST['editarcurso'] == null && @$_REQUEST['borrarcurso'] == null) 
		{	
			$this->Lista();		
		}else
		{
			if(@$_REQUEST['salir'] != null)
			{
				$this->usuario->LogOut();
			}
			elseif(@$_REQUEST['opcion'] == 'agregar')
			{
				$this->Mostrar();
			}
			elseif(@$_REQUEST['registrousr'] != null)
			{
				$this->Alta($_REQUEST);
			}
			elseif(@$_REQUEST['opcion'] == 'desplegar')
			{
				if(@$_REQUEST['dato']== 1){
				$this->MostrarBorrar(@$_REQUEST['id']);
				}
				if(@$_REQUEST['dato']== 2){
				$this->MostrarEditar(@$_REQUEST['id']);
				}
			}
			elseif(@$_REQUEST['editarcurso'] != null)
			{
				$this->Editar($_REQUEST);
			}
			elseif(@$_REQUEST['borrarcurso'] != null)
			{
				$this->Borrar(@$_REQUEST['idcurso']);
			}
		}
        // section -64--88-1-105--75424b28:1340c1872aa:-8000:0000000000000AFC end
    }

} /* end of class ControladorCurso */

?>